<template>
	<view>
		
		<view class="feedback">
			<view class="info">设备类型：{{deviceInfo.deviceName}}</view>
			<view class="info">设备名：{{deviceInfo.deviceNickName?deviceInfo.deviceNickName:'暂无'}}</view>
			<view class="info">设备编号：{{deviceInfo.deviceImei}}</view>
			<view class="input input1">
				<textarea v-model="form.content" placeholder="请输入反馈内容，我们会为您更好的服务"/>
			</view>
			<view class="input">
				<input v-model="form.contacts" placeholder="请输入姓名联系人"/>
			</view>
			<view class="input">
				<input v-model="form.contactsMobile" placeholder="请输入联系人电话"/>
			</view>
			
		</view>
		
			
		
		
		
		<view class="userbtn">
			<!-- <view class="btn btn1" @tap="backPage">取消</view> -->
			<view class="btn btn2" style="width:400rpx" @tap="submit">确认</view>
		</view>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceId:"",
				deviceInfo:{},
				form:{
				  "contacts": "",
				  "contactsMobile": "",
				  "content": "",
				  "customerDeviceId": undefined,
				  "deviceImei": "",
				  "deviceName": "",
				  "deviceType": undefined
				  
				}
			}
		},
		onLoad(e){
			this.deviceId = e.id;
			this.getInfo();
		},
		methods: {
			getInfo(){
				this.$http.deviceDetail({id:this.deviceId}).then(res=>{
					if(res.code==0){
						this.deviceInfo=res.device;
						this.form.customerDeviceId = this.deviceId;
						this.form.deviceImei = this.deviceInfo.deviceImei;
						this.form.deviceName = this.deviceInfo.deviceName;
						this.form.deviceType = this.deviceInfo.deviceType;
						
					}
				})
			},
			submit(){
				
				if(!this.form.content){
					this.$tools.msg("请输入反馈内容")
					return;
				}
				if(!this.form.contacts){
					this.$tools.msg("请输入姓名联系人")
					return;
				}
				if(!this.form.contactsMobile){
					this.$tools.msg("请输入联系电话")
					return;
				}
				
				this.$http.deviceFeedback(this.form).then(res=>{
					console.log(res);
					if(res.code==0){
						this.$tools.msg("反馈成功，请等待工作人员联系！")
						setTimeout(res=>{
							uni.navigateTo({
								url: `/pages/deviceDetail/deviceDetail?id=${this.deviceId}`,
								success: res => {},
								fail: () => {},
								complete: () => {}
							});
						},2000)
					}else{
						this.$tools.msg(res.msg);
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.feedback{
		padding:30rpx 30rpx;
		color:#999999;
		line-height:53rpx;
	}
	.input{
		background:#fff;
		margin-top:30rpx;
		display: flex;
		align-items: center;
		height:86rpx;
		border-radius: 10rpx;
		padding-left:20rpx;
		overflow: hidden;
	}
	.input input{
		width: 100%;
	}
	.input1{height:auto;}
	.input textarea{
		width: 100%;
		height:200rpx;
		padding-top:20rpx;
	}
	.userbtn{padding:50rpx 0;}
	
</style>
